﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSBackup_Web.Sources.Override
{
    public class FileDetail
    {
        private string fileName = string.Empty;
        private string diffName = string.Empty;
        private string to = string.Empty;
        private uint size = 0;
        private bool selected = false;
        private DateTime creationTime = DateTime.Now;

        /// <summary>
        /// 文件的绝对路径
        /// </summary>
        public string FileName
        {
            get
            {
                return fileName;
            }
            set
            {
                fileName = value;
            }
        }

        /// <summary>
        /// 文件名，不包括路径信息，只读
        /// </summary>
        public string OnlyName
        {
            get
            {
                int index = -1;
                if (fileName != null)
                {
                    index = fileName.LastIndexOf('\\');
                    if (index != -1)
                        return fileName.Substring(index + 1);
                    else
                        return fileName;
                }
                else
                    return string.Empty;
            }
        }

        public string DiffName
        {
            get
            {
                return diffName;
            }
            set
            {
                diffName = value;
            }
        }

        public string To
        {
            get
            {
                return to;
            }
            set
            {
                to = value;
            }
        }

        public uint Size
        {
            get
            {
                return size;
            }
            set
            {
                size = value;
            }
        }

        public bool Selected
        {
            get
            {
                return selected;
            }
            set
            {
                selected = value;
            }
        }

        public DateTime CreationTime
        {
            get
            {
                return creationTime;
            }
            set
            {
                creationTime = value;
            }
        }

        public override string ToString()
        {
            int index = 0;
            index = fileName.LastIndexOf('\\') + 1;
            if (index > 0)
                return fileName.Substring(index);
            else
                return base.ToString();
        }
    }
}
